package jpf.nextsearch.ds.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jpf.nextsearch.ds.model.types.ResourceActiveTable;
import jpf.nextsearch.ds.model.types.ResourceServiceType;
import jpf.nextsearch.ds.model.types.ResourceType;

/**
 * @author <a href="mailto:jacek.pruszkowski@gmail.com">Jacek Pruszkowski</a>
 */
@Entity
@Table(name = "RESOURCE")
public class ResourceVO {

	public static final int PATH_MAX_LENGTH = 1024; // TODO: ustawic sprawdzanie
	// przy dodawaniu do bazy
	// nie czy dluzdze
	// ologowac i sprawedzac logi w razie czego zwiekszyc

	public static final int NAME_MAX_LENGTH = 256;// TODO: jw.

	@Id
	@SequenceGenerator(name = "RESOURCE_SEQ", sequenceName = "RESOURCE_SEQ", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RESOURCE_SEQ")
	private Long id;

	@Column(name = "host_id", nullable = false)
	private Long hostId;

	@Column(name = "name", nullable = false, length = NAME_MAX_LENGTH)
	private String name;

	@Column(name = "path", length = PATH_MAX_LENGTH)
	private String path = null;

	@Column(name = "size", nullable = false)
	private Long size;

	@Column(name = "service_type", nullable = false)
	private ResourceServiceType serviceType = null;

	@Column(name = "active_table", nullable = false)
	private ResourceActiveTable activeTable = null;

	@Column(name = "resource_type", nullable = false)
	private ResourceType resourceType = null;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public void setServiceType(ResourceServiceType serviceType) {
		this.serviceType = serviceType;
	}

	public ResourceServiceType getServiceType() {
		return serviceType;
	}

	public void setActiveTable(ResourceActiveTable activeTable) {
		this.activeTable = activeTable;
	}

	public ResourceActiveTable getActiveTable() {
		return activeTable;
	}

	public void setSize(Long size) {
		this.size = size;
	}

	public Long getSize() {
		return size;
	}

	public String toString() {
		return getName();
	}

	public void setResourceType(ResourceType resourceType) {
		this.resourceType = resourceType;
	}

	public ResourceType getResourceType() {
		return resourceType;
	}

	public void setHostId(Long hostId) {
		this.hostId = hostId;
	}

	public Long getHostId() {
		return hostId;
	}

}
